<?php

$User = UserCheck($GL, $_GET['id']);
if ($User) {
    if ($_POST["check_yes"] != "yes") {
        $t_tpl = GetTpl("change");
        unset($Selects);
        $Selects[GetTariff($GL, $_GET['id'])] = "selected=\"selected\"";
        $msg = "Сменить тариф для пользователя <b>$User</b>?";
        $t_replace = array(
            "{msg}" => $msg,
            "{selected_0}" => $Selects[0],
            "{selected_1}" => $Selects[1],
           "{selected_2}" => $Selects[2],
            "{selected_3}" => $Selects[3],
           "{selected_4}" => $Selects[4],
           "{selected_5}" => $Selects[5],
           "{selected_6}" => $Selects[6],
           "{selected_7}" => $Selects[7]);
        foreach ($t_replace as $k => $v)
            $t_tpl = str_replace($k, $v, $t_tpl);
        $t_title = "Сменить тариф";
        $HEADER .=" - ".$t_title;
        $t_BODY = $t_tpl;
    }
    else {
        $ChangeTariff = UserTariffChange($GL, $_GET['id'], $_POST["tariff"]);
        if ($ChangeTariff == "changed") {
            Logger($LogFile, "ADMIN CHANGE TARIFF ($User ".$GL["TARIFF"][$_POST["tariff"]]["name"].")");
            header("Location: http://" . $SITE . "/?action=panel");
        }
        elseif ($ChangeTariff == "nochanged") {
            header("Location: http://" . $SITE . "/?action=error");
        }
        else {
            header("Location: http://" . $SITE . "/?action=error");
        }
    }
}
else {
    header("Location: http://" . $SITE . "/?action=error");
}

?>
